package jdbc;

import jdbc.util.InputField;
import jdbc.util.InputUtil;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.Scanner;

public class UpdateUserDemo {
    public static void main(String[] args) throws Exception {
//        Scanner scanner = new Scanner(System.in);
//        System.out.println("请输入用户名：");
//        String username = scanner.nextLine();
//        System.out.println("请输入新密码：");
//        String password = scanner.nextLine();
//        System.out.println("请输入新昵称：");
//        String nickname = scanner.nextLine();
        // 1. 注册驱动
//        Class.forName("com.mysql.cj.jdbc.Driver");
//        Connection connection = DriverManager.getConnection(
//                "jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
//                "root",
//                "root");
//        System.out.println("与数据库建立连接成功");
//        // 创建Statement语句对象
//        Statement statement = connection.createStatement();


//        String sql = "UPDATE user SET password = '"+password+"',nickname = '"+nickname+"' WHERE username = '"+username+"'";
//        int count = statement.executeUpdate(sql);// 返回值表示受影响的行数
//        System.out.println(count > 0 ? "修改成功" : "修改失败");


//        connection.close();


        User user = InputUtil.getInputObject(new User(), "欢迎注册");
        System.out.println(user);
    }
}
